package A12_线程池_ThreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 *
 * 线程池
 *
 *
 * @Author: KingWang
 * @Date: 2021/5/24
 * @Desc:
 **/
public class ExecutorServiceDemo {

    public static void main(String[] args) {
        ExecutorService threadPool1 = Executors.newFixedThreadPool(5);
        ExecutorService threadPool2= Executors.newSingleThreadExecutor();
        ExecutorService threadPool3 = Executors.newCachedThreadPool();

        try{
            for (int i = 0; i < 10 ; i++) {
                threadPool1.execute(()->{
                    System.out.println(Thread.currentThread().getName() + "\t 办理业务");
                });
            }
        }finally {
            threadPool1.shutdown();
        }

    }
}
